import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "@/assets/css/common.css";
import axios from "axios";
import VueAxios from "vue-axios";

Vue.config.productionTip = false;

Vue.use(ElementUI);
Vue.use(VueAxios, axios);

Vue.mixin({
  methods: {
    toRegister() {
      if (this.$route.path != "/user/register") {
        this.$router.push("/user/register");
      }
    },
    toLogin() {
      if (this.$route.path != "/user/login") {
        this.$router.push("/user/login");
      }
    },
    toHome() {
      if (this.$route.path != "/home") {
        this.$router.push("/home");
      }
    },
  },
});

axios.defaults.baseURL = "http://localhost:3000/api";
// // 从浏览器内存中调出jwt_token
// axios.defaults.headers = {
//   Authorization: "Bearer " + localStorage.getItem("jwt_token"),
// };

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
